<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
<h:outputStylesheet library="css" name="default.css" target="head" />
	<title>Modifica Prodotti</title>
</h:head>
<h:body>
<h:form id="ed">
<h:form>
		<p:toolbar style="heigh:35px">
			<p:toolbarGroup align="left" style="margin-top:5px; margin-left:10px">
		Benvenuto #{userBean.name} <p:separator /> #{userBean.mail}
		
		</p:toolbarGroup >
			<p:toolbarGroup align="right" >
			<p:selectOneMenu value="#{prodPresBean.currentlySelectedType}">
			<f:selectItem itemLabel="Select..." noSelectionOption="true"/>
			<f:selectItem itemLabel="Hotel" itemValue="hotel" />
			<f:selectItem itemLabel="Località" itemValue="località" />
			<f:selectItem itemLabel="Tour" itemValue="tour" />
			<f:selectItem itemLabel="Tratta" itemValue="tratta" />
			<f:selectItem itemLabel="Aeroporto" itemValue="aeroporto" />
			<f:selectItem itemLabel="Compagnia" itemValue="compagnia" />
			<f:ajax render=":ed:ll" />
		</p:selectOneMenu>
		
		<p:button value="Indietro" outcome="index.xhtml"/>
				<p:menuButton value="Opzioni">
					<p:menuitem value="Home" url="index.xhtml" icon="ui-icon-home" />
					<p:menuitem value="Visualizza Pacchetti" url="show_pacchetti.xhtml"
						icon="ui-icon-suitcase" />
					<p:menuitem value="Visualizza Prodotti" url="show_prodotti.xhtml"
						icon="ui-icon-clipboard" />
				</p:menuButton>
				<p:separator />
				<p:commandButton action="#{logBean.logout}" value="Logout"
					icon="ui-icon-power" />
			</p:toolbarGroup>
		</p:toolbar>
	</h:form>
	<h:form id="ll">
		<h:message for="generic_error" />
		<h:messages/>
	Seleziona il prodotto da mostrare
	
		
		<br />

<!-- HOTEL -->
		<p:dataTable value="#{prodPresBean.getAllHotels()}" var="hotel"
			rendered="#{prodPresBean.currentlySelectedType == 'hotel'}" id="hotels">
			
			
			<f:facet name="header">  
				Elenco Hotel 
				</f:facet>
				
				<p:column headerText="ID Hotel">
				<h:outputText value="#{hotel.ID}" />
				</p:column>
			
				<p:column headerText="Nome Hotel">
				<h:outputText value="#{hotel.nome}" />
				</p:column>

				<p:column headerText="Località">
				<h:outputText value="#{prodPresBean.getLocalità(hotel.localitàID).nome}" />
				</p:column>
				
				<p:column headerText="Stelle">
				<p:rating value="#{prodPresBean.stars(hotel)}" readonly="true" />
				</p:column>

			

			<p:column >
				<f:facet name="header">Modifica</f:facet>
				<p:button value="Modifica"
					outcome="edit_prodotti.xhtml?type=hotel&amp;nuovo=false&amp;ID=#{hotel.ID}" icon="ui-icon-pencil"/>
				<p:commandButton value="Elimina"
					action="#{prodPresBean.deleteHotel(hotel.ID)}" icon="ui-icon-closethick" update="hotels"/>
			</p:column>

		</p:dataTable>
		<p:button value="Aggiungi Hotel"
			outcome="edit_prodotti.xhtml?type=hotel&amp;nuovo=true"
			rendered="#{prodPresBean.currentlySelectedType == 'hotel'}" icon="ui-icon-plusthick"/>
			
<!-- LOCALITA' -->

		<p:dataTable value="#{prodPresBean.getAllLocalità()}" var="località"
			rendered="#{prodPresBean.currentlySelectedType == 'località'}" id="località">
		
		
		<f:facet name="header">  
				Elenco Località
				</f:facet>
				
				<p:column headerText="ID Località">
				<h:outputText value="#{località.ID}" />
				</p:column>
		
				<p:column headerText="Nome Località">
				<h:outputText value="#{località.nome}" />
				</p:column>
			
				<p:column headerText="Stato">
				<h:outputText value="#{località.stato}" />
				</p:column>

			
			<p:column>
				<f:facet name="header">Modifica</f:facet>
				<p:button value="Modifica"
					outcome="edit_prodotti.xhtml?type=località&amp;nuovo=false&amp;ID=#{località.ID}" icon="ui-icon-pencil"/>
				<p:commandButton value="Elimina"
					action="#{prodPresBean.deleteLocalita(località.ID)}" icon="ui-icon-closethick" update="località"/>
			</p:column>
		</p:dataTable>

		<p:button value="Aggiungi Località"
			outcome="edit_prodotti.xhtml?type=località&amp;nuovo=true"
			rendered="#{prodPresBean.currentlySelectedType == 'località'}" icon="ui-icon-plusthick"/>

<!-- TOUR -->

		<p:dataTable value="#{prodPresBean.getAllTours()}" var="tour"
			rendered="#{prodPresBean.currentlySelectedType == 'tour'}" id="tours">
			
			<f:facet name="header">  
				Elenco Tour 
				</f:facet>
				
				<p:column headerText="ID Tour">
				<h:outputText value="#{tour.ID}" />
				</p:column>
			<p:column headerText="Località">
				<h:outputText value="#{prodPresBean.getLocalità(tour.localitàID).nome}" />
				</p:column>
			
			<p:column headerText="Descrizione">
				<h:outputText value="#{tour.descrizione}" />
				</p:column>


		

			<p:column >
				<f:facet name="header">Modifica</f:facet>
				<p:button value="Modifica"
					outcome="edit_prodotti.xhtml?type=tour&amp;nuovo=false&amp;ID=#{tour.ID}" icon="ui-icon-pencil"/>
				<p:commandButton value="Elimina"
					action="#{prodPresBean.deleteTour(tour.ID)}" icon="ui-icon-closethick" update="tours"/>
			</p:column>
		</p:dataTable>

		<p:button value="Aggiungi Tour"
			outcome="edit_prodotti.xhtml?type=tour&amp;nuovo=true"
			rendered="#{prodPresBean.currentlySelectedType == 'tour'}" icon="ui-icon-plusthick"/>


<!-- TRATTA -->

		<p:dataTable value="#{prodPresBean.getAllTratte()}" var="tratta"
			rendered="#{prodPresBean.currentlySelectedType == 'tratta'}" id="tratte">

			<f:facet name="header">  
			Elenco Tratte 
			</f:facet>
			
			<p:column headerText="ID Tratta">
				<h:outputText value="#{tratta.ID}" />
			</p:column>
			
			<p:column headerText="Da">
				<h:outputText value="#{prodPresBean.getAeroporto(tratta.daAeroportoID).name}" />
			</p:column>
			
			<p:column headerText="A">
				<h:outputText value="#{prodPresBean.getAeroporto(tratta.adAeroportoID).name}" />
			</p:column>
			
			<p:column headerText="Compagnia">
				<h:outputText value="#{prodPresBean.getCompagnia(tratta.compagniaID).nome}" />
			</p:column>

		
			<p:column style="width:20%">
				<f:facet name="header">Modifica</f:facet>
				<p:button value="Modifica"
					outcome="edit_prodotti.xhtml?type=tratta&amp;nuovo=false&amp;ID=#{tratta.ID}" icon="ui-icon-pencil"/>
				<p:commandButton value="Elimina"
					action="#{prodPresBean.deleteTratta(tratta.ID)}" icon="ui-icon-closethick" update="tratte"/>
			</p:column>
		</p:dataTable>

		<p:button value="Aggiungi Tratta"
			outcome="edit_prodotti.xhtml?type=tratta&amp;nuovo=true"
			rendered="#{prodPresBean.currentlySelectedType == 'tratta'}" icon="ui-icon-plusthick"/>

<!-- AEROPORTO -->

		<p:dataTable value="#{prodPresBean.getAllAeroporti()}" var="aeroporto"
			rendered="#{prodPresBean.currentlySelectedType == 'aeroporto'}" id="aeroporti">

			
			<f:facet name="header">  
			Elenco Aeroporti  
			</f:facet>
			<p:column headerText="ID Aeroporto">
				<h:outputText value="#{aeroporto.ID}" />
			</p:column>
			
			<p:column headerText="Nome">
				<h:outputText value="#{aeroporto.name}" />
			</p:column>
			
			<p:column headerText="Località">
				<h:outputText value="#{prodPresBean.getLocalità(aeroporto.IDlocalità).nome}" />
			</p:column>
			

			<p:column >
				<f:facet name="header">Modifica</f:facet>
				<p:button value="Modifica"
					outcome="edit_prodotti.xhtml?type=aeroporto&amp;nuovo=false&amp;ID=#{aeroporto.ID}" icon="ui-icon-pencil"/>
				<p:commandButton value="Elimina"
					action="#{prodPresBean.deleteAeroporto(aeroporto.ID)}" icon="ui-icon-closethick" update="aeroporti"/>
			</p:column>
		</p:dataTable>

		<p:button value="Aggiungi Aeroporto"
			outcome="edit_prodotti.xhtml?type=aeroporto&amp;nuovo=true"
			rendered="#{prodPresBean.currentlySelectedType == 'aeroporto'}" icon="ui-icon-plusthick"/>


<!-- COMPAGNIE -->
		
			<p:dataTable id="compagnie" value="#{prodPresBean.getAllCompagnie()}"
				var="compagnia"
				rendered="#{prodPresBean.currentlySelectedType == 'compagnia'}">


				<f:facet name="header">  
				Elenco Compagnie 
				</f:facet>

				<p:column  headerText="ID Compagnia" >
					<h:outputText value="#{compagnia.ID}" />
				</p:column>

				<p:column headerText="Nome Compagnia" filterBy="#{compagnia.nome}" filterMatchMode="contains">
					<h:outputText value="#{compagnia.nome}" />
				</p:column>

			<p:column>
				<f:facet name="header">Modifica</f:facet>
				<p:button value="Modifica" 
					outcome="edit_prodotti.xhtml?type=compagnia&amp;nuovo=false&amp;ID=#{compagnia.ID}" icon="ui-icon-pencil" />
				<p:commandButton value="Elimina"
					action="#{prodPresBean.deleteCompagnia(compagnia.ID)}" icon="ui-icon-closethick" update="compagnie"/>
			</p:column>

			</p:dataTable>
			<br></br>
			<p:button value="Aggiungi" 
				outcome="edit_prodotti.xhtml?type=compagnia&amp;nuovo=true"
				rendered="#{prodPresBean.currentlySelectedType == 'compagnia'}" icon="ui-icon-plusthick" />
		
		
		
	</h:form>
</h:form>
</h:body>
</html>